package com.example.demo.model;


import com.example.demo.entity.ProductSupplier;
import com.example.demo.mapper.SupplierMapper;
import com.example.demo.request.Supplier.ListRequest;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Model{
    private  Map wheres = new HashMap<String,String>();
    private  Map options = new HashMap<String,String>();
    private int pageLow;
    private int pageUp;
    private int pageSize = 20;

    public void where(String field, String value) {

    }
    public String whereLike(String field) {
        if(field == null || field.equals("")){
           return null;
        }
        return "%"+ field + "%";
    }

    public int[] getPage(Integer page_size, Integer page_no) {
        int[] page = new int[2];
        page[0] = page_size * page_no;
        page[1] = page_size * (page_no - 1);
        return page;
    }


    protected Map<String, Object> toPage(List list, ListRequest listRequest) {
        Map<String,Object> map =  new HashMap<>();
        map.put("page_no",listRequest.page_no);
        map.put("page_size",listRequest.page_size);
        map.put("datalist",list);
        return map;
    }


}
